<template>
  <div>
     <x-header :left-options="{backText: ''}"  style="background-color:#000;">更多信息</x-header>
     <div class="weui-cells__title g-c--red">*基本信息</div>
     <group label-width="6.5em">
      <cell primary="content" title="批发价格*" :value="price+' 万元'"></cell>
      <cell title="车辆类型*" :value="carType"></cell>
      <cell title="品牌型号*" :value="brand"></cell>
      <cell title="是否上牌*" :value="licensePlate"></cell>
      <cell title="初次上牌时间*" :value="licensePlateTime"></cell>
      <cell title="行程里数*" :value="mileage+' 万公里'"></cell>
      <cell title="变速箱*" :value="gearbox"></cell>
      <cell title="交强险有效期*" :value="insurance"></cell>
      <cell title="年审时间*" :value="annualVerificationDate"></cell>
      <cell title="燃油类型*" :value="fuel"></cell>
      <cell title="过户次数*" :value="transferNum"></cell>
    </group>
    <div class="weui-cells__title g-c--red">*车况信息</div>
    <group label-width="6.5em">
      <cell title="事故情况*" :value="accident"></cell>
      <cell title="钣金情况*" :value="sheetMetal"></cell>
      <cell title="漆面情况*" :value="paint"></cell>
      <cell title="内饰情况*" :value="trim"></cell>
    </group>
    <div class="weui-cells__title g-c--red">*其他信息</div>
    <group label-width="6.5em">
      <cell title="车辆过户*" :value="transfer"></cell>
      <cell title="能否按揭*" :value="mortgage"></cell>
      <cell title="VIN码*" :value="vinCode"></cell>
      <cell title="车身颜色*" :value="carColor"></cell>
      <cell title="原车用途*" :value="use"></cell>
      <cell title="排放标准*" :value="discharge"></cell>
    </group>
    <div class="weui-cells__title g-c--red">*车辆描述</div>
    <group>
      <cell-box style="min-height:100px;color:#999999">
        {{carInfo}}
      </cell-box>
    </group>
  </div>
</template>
<script>
import qs from "qs";
import {
  Cell,
  CellBox,
  CellFormPreview,
  Group,
  Badge,
  XHeader,
  Actionsheet,
  ButtonTab,
  ButtonTabItem
} from "vux";

export default {
  components: {
    Cell,
    CellBox,
    CellFormPreview,
    Group,
    Badge,
    XHeader,
    Actionsheet,
    ButtonTab,
    ButtonTabItem
  },
  data() {
    return {
      price: "***",
      carType: "",
      brand: "",
      licensePlate: "",
      licensePlateTime: "",
      mileage: 12,
      gearbox: "",
      insurance: "",
      annualVerificationDate: "",
      fuel: "",
      transferNum: 2,
      accident: "",
      sheetMetal: "",
      paint: "",
      trim: "",
      transfer: "",
      mortgage: "",
      vinCode: "",
      carColor: "",
      use: "",
      discharge: "",
      carInfo: ""
    };
  },
  beforeCreate() {
    let _this = this;
    let carId = this.$route.params.car_id;
    console.log(carId);
    this.$http
      .post(
        "/car/getCarDetail",
        qs.stringify({
          car_id: carId
        })
      )
      .then(res => {
        let data = res.data;
        console.log("获取车辆更多详情接口:", data);
        this.price = data.price;
        this.carType = data.model;
        this.brand = data.all_name;
        this.licensePlate =
          parseInt(data.is_licensed) === 1 ? "上牌" : "没上牌";
        this.licensePlateTime = data.license_date;
        this.mileage = data.km;
        this.gearbox = data.transmission;
        this.insurance = data.insurance_date;
        this.annualVerificationDate = data.inspection_date;
        this.fuel = data.fuel;
        this.transferNum = data.guohu_num;
        this.accident = data.shigu;
        this.sheetMetal = data.banjin;
        this.paint = data.qimian;
        this.trim = data.neishi;
        this.transfer = parseInt(data.is_transfer) === 1 ? "能" : "不能";
        this.mortgage = parseInt(data.is_mortgage) === 1 ? "能" : "不能";
        this.vinCode = data.vin_code;
        this.carColor = data.color;
        this.use = data.use;
        this.discharge = data.emission;
        this.carInfo = data.detail;
      });
  }
};
</script>
<style scoped>
.weui-cells__title.g-c--red {
  margin-bottom: -1em;
}
</style>
